<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Payment\PaymentChannel;

class CreatePaymentChannelsTable extends Migration
{


    const TABLE = PaymentChannel::TABLE;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        !Schema::hasTable(self::TABLE) &&
        Schema::create(self::TABLE, function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('category', 50)->default('')->comment('类型');
            $table->string('name', 50)->default('')->comment('名称');
            $table->uuid('parking_lot_id')->index()->comment('车场ID');
            $table->boolean('disabled')->default(false)->comment('是否禁用');
            $table->json('parameters')->nullable()->comment('参数');
            $table->text('key_file')->nullable()->comment('支付校验文件');
            $table->text('cert_file')->nullable()->comment('支付校验文件');
            $table->string('remark')->default('');
            $table->timestamps();
        });

        DB::statement("alter table `".self::TABLE."` comment '支付通道';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(self::TABLE);
    }
}
